beta_changesfandomcom-20200213-history
MS-DOS:1.25:Z-100 OEM:1.01:8-11-1983/disk02/BMSDOS.ASM
BIOS for MS-DOS assembler source file. File content PAGE ,132 TITLE BIOS for MS-DOS .LFCOND .TFCOND ; Use the /X switch to cause FALSE conds not to be listed IF1 %OUT *Pass 1 started* ENDIF IF2 %OUT *Pass 2 started* ENDIF ; BIOS for MS-DOS ; ; This is the so called Basic I/O ; System for MS-DOS. ; ; It is loaded into memory at a known ; location by the MS-DOS Loader. ; ; 10/28/82 - release 1.10 (Shipping version w/winchester) ; ; ©COPYRIGHT 1982 BY ZENITH DATA SYSTEMS ; INCLUDE PARMS.ASM ; Get program parms IF LISTI IF1 %OUT *Full listing being generated* ENDIF ELSE IF1 %OUT *Include files are not part of listing* ENDIF .XLIST ENDIF CC_CR EQU 0DH CC_LF EQU 0AH INCLUDE DEFCONFG.ASM ; Z-100 system configuration INCLUDE DEFMTR.ASM ; ROM based monitor INCLUDE DEFFMT.ASM ; Loader header INCLUDE DEF6821.ASM ; 6821 PIA INCLUDE DEFEP2.ASM ; 2661 UART INCLUDE DEFCHR.ASM ; Character device driver INCLUDE DEF8253.ASM ; 8253 programmable interval timer INCLUDE DEF8259A.ASM ; 8259A interrupt controller INCLUDE DEFZ207.ASM ; Z-207 Disk controller INCLUDE DEFZ217.ASM ; Z-217 Disk Controller INCLUDE DEFSBC.ASM ; SBC definitions INCLUDE DEFDSK.ASM ; Disk driver INCLUDE DEFMS.ASM ; MS-DOS INCLUDE DEFIPAGE.ASM ; Interrupt page defs INCLUDE MACLIB.ASM ; Macro library .LIST PAGE ; ; BIOS Jump vector for individual routines ; (This must located at the very beginning of the BIOS) ; BIOS_SEG SEGMENT PUBLIC 'BIOSCODE' ASSUME CS:BIOS_SEG,DS:BIOS_SEG,ES:NOTHING,SS:BIOS_SEG EXTRN BIOS_READ:FAR EXTRN BIOS_WRITE:FAR EXTRN BIOS_DSKCHG:FAR EXTRN BIOS_MAPDEV:FAR EXTRN BIOS_DSKFUNC:FAR EXTRN BIOS_PRNFUNC:FAR EXTRN BIOS_AUXFUNC:FAR EXTRN BIOS_CONFUNC:FAR EXTRN DSK_TPTR:WORD EXTRN DSK:NEAR EXTRN DSK_WCB:BYTE EXTRN DISK4:BYTE EXTRN DISK5:BYTE EXTRN CHRD_PRN:BYTE EXTRN CHRD_AUX:BYTE EXTRN CHRD_CON:BYTE EXTRN CQ_ZCON:NEAR EXTRN CQ_ZSERA:NEAR EXTRN CQ_ZSERB:NEAR EXTRN DSKT_FG:BYTE EXTRN DSKT_PORT:WORD EXTRN DSKT_DNCTR:WORD EXTRN DSKT_DSEL:BYTE EXTRN BIOS_SIZE:NEAR EXTRN ISR_KD:NEAR EXTRN ISR_ULP:NEAR EXTRN ISR_UKB:NEAR EXTRN ISR_USAI:NEAR EXTRN ISR_USBI:NEAR EXTRN ISR_USAO:NEAR EXTRN ISR_USBO:NEAR EXTRN ISR_UCRT:NEAR EXTRN ISR_PRSC:NEAR EXTRN KQ_PUT:FAR EXTRN VSYNC_CNT:WORD EXTRN VIDEO_ROM:BYTE EXTRN VIDEO_PGM:BYTE EXTRN ISR_SA:NEAR EXTRN ISR_SB:NEAR PUBLIC ASP_LPEFV PUBLIC ASP_LPHFV PUBLIC ASP_LPHCAV PUBLIC ASP_LPHPAV PUBLIC PRSC_IN_PROGRESS PUBLIC RECURLV PUBLIC SAVESS PUBLIC SAVESP PUBLIC DSKPR PUBLIC BIOS_INIT PUBLIC BIOS_STATUS PUBLIC BIOS_CONIN PUBLIC BIOS_CONOUT PUBLIC BIOS_PRINT PUBLIC BIOS_AUXIN PUBLIC BIOS_AUXOUT PUBLIC BIOS_SETDATE PUBLIC BIOS_SETTIME PUBLIC BIOS_FLUSH PUBLIC ALARM_ST PUBLIC ALARM_CK PUBLIC ALARM_SP PUBLIC ALARM_WAIT PUBLIC PMESG PAGE BIOSP PROC FAR ORG 0 ; MicroSoft(MS) defined entries JMP NEAR PTR BIOS_INIT ; Initialization code JMP NEAR PTR BIOS_STATUS ; Console input status JMP NEAR PTR BIOS_CONIN ; Console input JMP NEAR PTR BIOS_CONOUT ; Console output JMP NEAR PTR BIOS_PRINT ; Printer output JMP NEAR PTR BIOS_AUXIN ; Aux input JMP NEAR PTR BIOS_AUXOUT ; Aux output JMP NEAR PTR BIOS_READ ; Disk input JMP NEAR PTR BIOS_WRITE ; Disk output JMP NEAR PTR BIOS_DSKCHG ; Disk change status JMP NEAR PTR BIOS_SETDATE ; Set current date JMP NEAR PTR BIOS_SETTIME ; Set current time JMP NEAR PTR BIOS_GETDATE ; Read time and date JMP NEAR PTR BIOS_FLUSH ; Flush keyboard input buffer JMP NEAR PTR BIOS_MAPDEV ; Device mapping JMP NEAR PTR BIOS_RES ; Reserved 9 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 8 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 7 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 6 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 5 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 4 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 3 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 2 by MS for expansion JMP NEAR PTR BIOS_RES ; Reserved 1 by MS for expansion ; Zenith Data Systems(ZDS) defined entries JMP NEAR PTR BIOS_DSKFUNC ; Disk function JMP NEAR PTR BIOS_PRNFUNC ; PRN: function JMP NEAR PTR BIOS_AUXFUNC ; AUX: function JMP NEAR PTR BIOS_CONFUNC ; CON: function JMP NEAR PTR BIOS_RES ; Reserved 4 by ZDS for expansion JMP NEAR PTR BIOS_RES ; Reserved 3 by ZDS for expansion JMP NEAR PTR BIOS_RES ; Reserved 2 by ZDS for expansion JMP NEAR PTR BIOS_RES ; Reserved 1 by ZDS for expansion DB BIOS_CREL ; Release of the BIOS in bcd (ie 010H for release 1.0x) DW OFFSET CONFG_INFO ; Addr of configuation info SMESG DB CC_CR,CC_LF,CC_LF DB 'Z-DOS/MS-DOS BIOS release 1.00, version 1.10 ' ; This must match above IF1 %OUT *Z-DOS/MS-DOS BIOS release 1.00, version 1.10* ENDIF DB CC_CR,CC_LF,CC_LF SMESGL EQU (OFFSET $)-(OFFSET SMESG) DB '©COPYRIGHT 1982 BY ZENITH DATA SYSTEMS' DB CC_CR,CC_LF,CC_LF DB 'FOR TECHNICAL ASSISTANCE, CALL:' DB CC_CR,CC_LF,CC_LF DB '(616) 982-3860' DB CC_CR,CC_LF,CC_LF DB 'BETWEEN 8:00 AM AND 4:30 PM (EST) ON NORMAL BUSINESS DAYS' DB CC_CR,CC_LF,CC_LF PAGE ; ; Fake up some interrupt service routines for now ; (let them fall through to WILD INTERRUPT) ; ISR_SLV: ; Slave ISR_PP: ; Parallel ISR_SLV0: ; Source 0 on Slave ISR_SLV1: ; Source 1 on Slave ISR_SLV2: ; Source 2 on Slave ISR_SLV3: ; Source 3 on Slave ISR_SLV4: ; Source 4 on Slave ISR_SLV5: ; Source 5 on Slave ISR_SLV6: ; Source 6 on Slave ISR_SLV7: ; Source 7 on Slave ; ; Wild Interrupt trap ; (You get here if you do an interrupt which hasn't been ; changed from init time) ISR_WILD: INC WORD PTR CS:RECURLV ; Bump recursion level, first time through ? JNZ INT_TR1 ; No, skip MOV CS:SAVESS,SS ; Yes, save old stack MOV CS:SAVESP,SP PUSH CS ; Set up local stack POP SS MOV SP,OFFSET BIOS_SIZE+BIOS_WORKSP INT_TR1: STI ; Turn interrupts back on PUSH DS ; Save some regs PUSH AX PUSH CX PUSH BX PUSH CS ; Set up DS POP DS MOV BX,OFFSET IMESG ; Get addr of message MOV CH,OFFSET IMESGL ; Get length of message CALL PMESG ; Print message POP BX ; Restore the regs POP CX POP AX POP DS CLI ; Turn interrupts off (for a bit) DEC WORD PTR CS:RECURLV ; Decr recursion level, at bottom yet ? JNS INT_TR2 ; No, skip MOV SS,CS:SAVESS ; Yes, restore stack MOV SP,CS:SAVESP INT_TR2: IRET ; Return IMESG DB CC_CR,CC_LF,CC_LF DB 'WILD INTERRUPT' DB CC_CR,CC_LF,CC_LF IMESGL EQU (OFFSET $)-(OFFSET IMESG) PAGE ; ; Fatal Error - Memory Parity or S-100 buss error ; ISR_EI: MOV CS:SAVESP1,SP ; Save SP(in special place) INC WORD PTR CS:RECURLV ; Bump recursion level, first time through ? JNZ INT_EI1 ; No, skip MOV CS:SAVESS,SS ; Yes, save old stack MOV CS:SAVESP,SP MOV SP,CS ; Set up local stack MOV SS,SP MOV SP,OFFSET BIOS_SIZE+BIOS_WORKSP INT_EI1: MOV CS:SAVEAX,AX ; Save Regs MOV CS:SAVEDS,DS PUSH CS ; Set up DS POP DS MOV AL,BYTE PTR BIOS_MCL ; Get memory control latch value AND AL,NOT ZMCLPK ; Turn off parity checking OUT ZMCL,AL ; Save registers on stack PUSH BP PUSH SI PUSH DI PUSH DX PUSH CX PUSH BX PUSH SAVEAX PUSH SAVESP1 PUSH SAVESS PUSH ES PUSH SAVEDS MOV BX,SAVESP1 MOV DS,SAVESS PUSH 2BX ; CS PUSH 0BX ; IP PUSH 4BX ; Flags MOV AX,CS ; Set up DS and ES MOV DS,AX MOV ES,AX ; For each register on stack, store it's hex value in print buffer MOV BP,SP ; Get base of values MOV DI,OFFSET EIMESG1+3 ; Get address to store value MOV CX,14 ; Get number of registers EILOOP: MOV AL,BYTE PTR 1BP ; Get high byte of register CALL EIDBYTE ; Store that byte MOV AL,BYTE PTR 0BP ; Get low byte of register CALL EIDBYTE ; Store that byte ADD BP,2 ; Point to next register ADD DI,6 ; Point to next place to store string LOOP EILOOP ; Do it again ; Print message CALL FAR PTR MTR_TTY_INTR ; Force scroll MOV BX,OFFSET EIMESG ; Get addr of message MOV CH,OFFSET EIMESGL ; Get length of message CALL PMESG ; Print message CALL FAR PTR MTR_TTY_INTR ; Force scroll ; Restore registers POP BP ; Flags POP BP ; IP POP BP ; CS POP BP ; DS POP ES POP BP ; SS POP BP ; SP POP AX POP BX POP CX POP DX POP DI POP SI POP BP ; Restore stack CLI ; Turn interrupts off (for a bit) DEC WORD PTR RECURLV ; Decr recursion level, at bottom yet ? JNS INT_EI2 ; No, skip MOV SS,SAVESS ; Yes, restore stack MOV SP,SAVESP INT_EI2: JMP INT_EI2 ; Loop forever MOV AH,BYTE PTR BIOS_EDCNT ; Get down counter OR AH,AH ; Is it down to zero ? JZ INT_EI3 ; Yes, skip DEC AH ; Bump it down MOV BYTE PTR BIOS_EDCNT,AH ; Store new value JMP INT_EI4 ; Skip INT_EI3: MOV AL,BYTE PTR BIOS_MCL ; Get memory control latch value AND AL,NOT ZMCLPK ; Turn off memory parity checking MOV BYTE PTR BIOS_MCL,AL ; Store new value INT_EI4: MOV AL,OCW2OP+OCW2EOI ; Tell 8259A that interrupt serviced OUT ZM8259A+OCW2,AL MOV AL,BYTE PTR BIOS_MCL ; Get memory control latch value OUT ZMCL,AL ; Set value MOV AX,CS:SAVEAX ; Restore regs MOV DS,CS:SAVEDS IRET ; and return ; ; EIDBYTE - Hex display routines ; ; Call with: ; AL = value ; ES:DI -> place to store string ; ; Returns: ; DI - updated ; ; Uses: AL, AH ; EIDBYTE PROC NEAR DB 0D4H,010H ; Separate hex digits in AH, AL XCHG AL,AH ; Change order for STOSB ADD AL,090H ; "Trick" procedure to convert to ASCII DAA ADC AL,040H DAA STOSB MOV AL,AH ADD AL,090H DAA ADC AL,040H DAA STOSB RET EIDBYTE ENDP SAVESP1 DW ? SAVEDS DW ? SAVEAX DW ? EIMESG DB CC_CR,CC_LF DB 'ERROR - MEMORY PARITY OR BUSS' DB CC_CR,CC_LF,CC_LF EIMESG1 DB "F =0000 IP=0000 CS=0000 DS=0000 ES=0000 SS=0000 SP=0000" DB CC_CR,CC_CR,CC_LF DB "AX=0000 BX=0000 CX=0000 DX=0000 DI=0000 SI=0000 BP=0000" DB CC_CR,CC_LF,CC_LF DB "SYSTEM HALT" DB CC_CR,CC_LF EIMESGL EQU (OFFSET $)-(OFFSET EIMESG) PAGE ; ; BIOS reserved function entry point trap ; (You get here if you do an BIOS call to a reserved entry point) ; BIOS_RES PROC FAR CLI ; Turn off interrupts INC WORD PTR CS:RECURLV ; Bump recursion level, first time through ? JNZ BIOS_RES1 ; No, skip MOV CS:SAVESS,SS ; Yes, save old stack MOV CS:SAVESP,SP PUSH CS ; Set up local stack POP SS MOV SP,OFFSET BIOS_SIZE+BIOS_WORKSP BIOS_RES1: STI ; Turn interrupts back on PUSH DS ; Save some regs PUSH AX PUSH CX PUSH BX PUSH CS ; Set up DS POP DS MOV BX,OFFSET RSMESG ; Get addr of message MOV CH,OFFSET RSMESGL ; Get length of message CALL PMESG ; Print message POP BX ; Restore the regs POP CX POP AX POP DS CLI ; Turn interrupts off (for a bit) DEC WORD PTR CS:RECURLV ; Decr recursion level, at bottom yet ? JNS BIOS_RES2 ; No, skip MOV SS,CS:SAVESS ; Yes, restore stack MOV SP,CS:SAVESP BIOS_RES2: STI ; Turn interrupts back on RET ; Return RSMESG DB CC_CR,CC_LF,CC_LF DB 'RESERVED BIOS ENTRY POINT CALLED' DB CC_CR,CC_LF,CC_LF RSMESGL EQU (OFFSET $)-(OFFSET RSMESG) BIOS_RES ENDP PAGE ; ; PMESG - Print a message on the console ; ; Call with: ; BX -> message to print ; CH = length of message ; ; Uses: AX, BX, CX ; PMESG PROC NEAR MOV AL,BX ; Get next character PUSH CS ; Make call into CALL FAR CALL NEAR PTR BIOS_CONOUT ; Print character in AL INC BX ; Bump char pointer DEC CH ; Decr remaining characters, Finished ? JNZ PMESG ; No, keep going RET ; Yes, return PMESG ENDP PAGE ; Recursion variables(so BIOS can call itself) RECURLV DW -1 ; Recursion level SAVESS DW ? ; Save area for SS SAVESP DW ? ; Save area for SP ; Font table information(must be together) FNT_INFO LABEL BYTE FNT_RAM DD ? ; Addr of font table setup at boot time FNT_ROM DD ? ; Addr of font table in ROM monitor FNT_SIZE DW ? ; Size of font table FNT_MSIZE DW ? ; Maximum size allocated for font table ; Memory information(Must be together) BIOS_MCL DB ZSM0+ZRM2+ZMCLPZ+ZMCLPK ; Select map 0 with ROM at top ; of addr space, parity gen and checking enabled BIOS_EDCNT DB 0 ; Error down counter ; Disk table DSKPR DB DSKPR_SIZE DUP(?) ; Parameter packet for call to DSK ; ; Configuration vector ; ; NOTE: ERRNZ macros can't be used in the config and ASP tables ; here (their conditionaled out of DEFMS.ASM) so anyone playing ; in this area PLEASE be careful! ; CONFG_INFO: DW OFFSET DSK_TPTR ; Addr of disk table vector DW OFFSET CHRD_PRN ; Addr of PRN: configuration table DW OFFSET CHRD_AUX ; Addr of AUX: configuration table DW OFFSET CHRD_CON ; Addr of CON: configuration table DW OFFSET FNT_INFO ; Addr of FONT information DW OFFSET BIOS_DATE_TIME ; Addr of date and time fields DW OFFSET DISK_TAB ; Addr of DOS disk table DW OFFSET BIOS_MCL ; Addr of Memory control info DW OFFSET BIOS_ASP ; Addr of aspect ration information DW OFFSET CQ_ZCON ; Addr of descriptor for CON que DW OFFSET CQ_ZSERA ; Addr of descriptor for Serial A que DW OFFSET CQ_ZSERB ; Addr of descriptor for Serial B que DW -1 BIOS_ASP LABEL NEAR DB ASP_X ; Aspect ratio X value DB ASP_Y ; Aspect ratio Y value ASP_LPEFV DW 5 ; Default light pen error ASP_LPHFV DB 0 ; Show no hits so far ASP_LPHCAV DW 0 ; Character address of hit ASP_LPHPAV DB 0 ; Pixel address of hit PRSC_IN_PROGRESS DB 0 ; != 0 if print screen in progress FNT_TAB: ; Start of font table (overlays Init code) SUBTTL BINIT - Initialization routines PAGE INCLUDE BINIT.ASM SUBTTL BCONIO - BIOS console entry points PAGE INCLUDE BCONIO.ASM SUBTTL BPRNIO - BIOS printer entry points PAGE INCLUDE BPRNIO.ASM SUBTTL BAUXIO - BIOS aux entry points PAGE INCLUDE BAUXIO.ASM SUBTTL BCLOCK - BIOS clock entry points and clock driver PAGE INCLUDE BCLOCK.ASM SUBTTL BDOSTB - Disk tables for MS-DOS PAGE INCLUDE BDOSTB.ASM BIOSP ENDP BIOS_SEG ENDS END ����������������������������������������������������������������������������